package br.quest;

public class Config {

    private static int gpsMinAccuracy = 10;
    private static int gpsMinDistance = 0;
    private static int gpsMinTime = 5000;
    private static double mathRamerEpsilon = 0;
    private static PreferenceManager preferences = null;

    /**
     * Makes this class non-instanciable. We just want to access its static methods to handle the app's configs.
     */
    private Config() {
    }
    
    /**
     * Checks if the configurations have already been loaded
     * @return True if the default configurations are loaded
     */
    public static boolean isConfigsLoaded() {
        return (preferences != null);
    }
    
    /**
     * Loads all the default configurations.
     */
    public static void loadConfigs() throws Exception {
        preferences = PreferenceManager.get();
        gpsMinAccuracy = preferences.getInt("gps_min_acc", 10);
        gpsMinDistance = preferences.getInt("gps_min_distance", 0);
        gpsMinTime = preferences.getInt("gps_min_time", 5000);
    }
    
    public static int getGpsMinAccuracy() {
        return gpsMinAccuracy;
    }
    
    public static int getGpsMinDistance() {
        return gpsMinDistance;
    }
    
    public static int getGpsMinTime() {
        return gpsMinTime;
    }
    
    public static double getMathRamerEpsilon() {
        return mathRamerEpsilon;
    }

    public static void setGpsMinAccuracy(int gpsMinAccuracy) {
        Config.gpsMinAccuracy = gpsMinAccuracy;
        preferences.savePreference("gps_min_acc", gpsMinAccuracy);
    }

    public static void setGpsMinDistance(int gpsMinDistance) {
        Config.gpsMinDistance = gpsMinDistance;
        preferences.savePreference("gps_min_distance", gpsMinDistance);
    }
    
    public static void setGpsMinTime(int gpsMinTime) {
        Config.gpsMinTime = gpsMinTime;
        preferences.savePreference("gps_min_time", gpsMinTime);
    }
    
    public static void setMathRamerEpsilon(double epsilon) {
        Config.mathRamerEpsilon = epsilon;
    }
}